package com.junzhiit.nengji.cms.web.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bainaeco.framework.util.AssertUtil;
import com.junzhiit.nengji.cms.service.PromotionPosterService;
import com.junzhiit.nengji.cms.web.vo.DataTablesParamVO;
import com.junzhiit.nengji.cms.web.vo.PromotionPosterVO;
import com.junzhiit.nengji.cms.web.vo.ResultVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/promotion/poster")
public class PromotionPosterController extends BaseController {

	@Autowired
	PromotionPosterService promotionPosterService;
	
	@ApiOperation(value="推广海报设置")
	@RequestMapping(value="/set",method=RequestMethod.POST)
	public ResultVO promotionPosterSet(PromotionPosterVO ppv){
		return promotionPosterService.promotionPosterSet(ppv);
	}
	
	@ApiOperation(value="获取推广海报列表")
	@RequestMapping(method=RequestMethod.GET)
	public Map<String,Object> findAll(DataTablesParamVO dtp,PromotionPosterVO ppv){
		AssertUtil.notBlank(ppv.getSessionId(), "sessionId is required.");
		return promotionPosterService.findAll(dtp, ppv);
	}
	
	@ApiOperation(value="根据id获取推广海报")
	@RequestMapping(value="/id",method=RequestMethod.GET)
	public ResultVO findById(PromotionPosterVO ppv){
		AssertUtil.notBlank(ppv.getSessionId(), "sessionId is required.");
		return promotionPosterService.findById(ppv);
	}
	
	@ApiOperation(value="根据id获取推广海报")
	@RequestMapping(value="/download",method=RequestMethod.POST)
	public void download(HttpServletResponse response,HttpServletRequest request,PromotionPosterVO ppv){
		AssertUtil.notBlank(ppv.getSessionId(), "sessionId is required.");
		AssertUtil.notBlank(ppv.getId(), "id is required.");
		promotionPosterService.download(response, request,ppv);
	}
}
